#ifndef L2_DATASET_HPP
#define L2_DATASET_HPP

#define PORT_MEMBLOCK_SIZE 32
#define PORT_MEM_ALIGN  4

#include "List.hpp"

class DataSet {
public:
    enum class DataType {
        Invalid,
        Boolean,
        Number,
        String,
    };

    enum ErrorNumber {
        Error_None = 0,
        Error_IllegalIndex = 1,
        Error_DataTypeError = 2,
        Error_NullLabel = 3,
        Error_NullString = 4,
        Error_AddDataWithExistLabel = 5, 
        Error_LabelNotExist = 6,
        Error_MallocFailed = 7,
        Error_FreeFailed = 8,
        Error_DataSetError = 9,
    };

    struct Data {
        DataType data_type;
        unsigned int label_size;
        unsigned int value_size;
        char *label;
        void *value;
    };

public:
    virtual ~DataSet();
    virtual bool add(const char *label,bool value);
    virtual bool add(const char *label,double value);
    virtual bool add(const char *label,const char *value);
    virtual bool remove(const char *label);
    virtual bool set(const char *label,bool value);
    virtual bool set(const char *label,double value);
    virtual bool set(const char *label,const char *value);
    virtual bool getBoolean(const char *label);
    virtual double getNumber(const char *label);
    virtual const char *getString(const char *label);
    virtual bool hasLabel(const char *label);
    virtual DataType getDataType(const char *label);

    virtual bool clear(void);
    virtual int getDataCount(void);
    virtual struct Data *getDataItem(int pos);

    virtual int getErrorNumber(void);
protected:
    List<struct Data*> dataset;
    int error_number;
};

#endif